package com.jzo2o.orders.manager.Handler.OrdersHandler;

import com.jzo2o.orders.base.model.domain.Orders;
import com.jzo2o.orders.manager.model.dto.request.PlaceOrderReqDTO;
import com.jzo2o.orders.manager.service.IOrdersCreateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 订单保存数据库Handler
 */
@Slf4j
@Component
@Order(40)  // 第四个执行
public class OrderSaveDbHandlerNew extends OrdersHandlerNew {
    private final IOrdersCreateService ordersService;

    public OrderSaveDbHandlerNew(IOrdersCreateService ordersService) {
        this.ordersService = ordersService;
    }


    @Override
    public void process(Orders order, PlaceOrderReqDTO reqDTO) {
        log.info("订单保存数据库Handler");
        ordersService.save(order);
    }
    
    @Override
    public int getOrder() {
        return 40;
    }
}